/**
 * Created by bdqn on 2016/5/3.
 */
//登录的方法
function login(){
	$.ajax({
		url:"http://localhost:8081/user/login",
		data:{name:$("#loginName").val(),pwd:$("#password").val()},
		type:"post",
		dataType:"json",
		success:function(data){
			if(data.obj!=null){
				sessionStorage.setItem("loginName",$("#loginName").val())
				sessionStorage.setItem("type",data.obj.type)
				location.href="index.html"
			}else{
				alert(data.obj.msg)
			}
		},error:function(){
			alert("错误")
		}
	})
}
function hqyzm(){
			$.ajax({
				url:"http://localhost:8081/user/hqyz",
				data:{name:$("#mobile").val()},
				type:"post",
				dataType:"json",
				success:function(data){
					if(data.obj!=null){
						sessionStorage.setItem("sj",data.obj.mobile)
						sessionStorage.setItem("yz",data.msg)
					}else{
						alert(data.msg)
					}

				},error:function(){
					alert("错误")
				}
			})
		}
function sjLogin(){
	var sj=sessionStorage.getItem("sj");
	var yz=sessionStorage.getItem("yz")
	var ssj=$("#mobile").val();
	var syz=$("#yzm").val();
	if(sj==ssj&&yz==syz){
		$.ajax({
			url:"http://localhost:8081/user/sjLogin",
			data:{name:$("#mobile").val()},
			type:"post",
			dataType:"json",
			success:function(data){
				sessionStorage.removeItem("sj");
				sessionStorage.removeItem("yz");
				sessionStorage.setItem("loginName",data.obj.loginName)
				sessionStorage.setItem("loginId",data.obj.id)
				alert("登录成功")
				location.href="index.html"
			}
		})
	}else{
		alert("登录失败")
	}
}